<?php
/**
 * Author: Hancock
 * Email: 84622365@qq.com
 * Date: 3/23/2016
 * Des: 工厂
 */
defined('INHkMvc') or exit('Access Invalid!');

class Factory
{
    public static function register($class, $type = "class", $param = '')
    {
        if ($type == "core") {
            if (file_exists(LIBS_PATH . "core" . SEPARATE . $class . '.class.php')) {
                if ($param != '') {
                    return new $class($param);
                } else {
                    return new $class;
                }
            } else {
                LD("$class is missing");
            }
        } else {
            if (file_exists(LIBS_PATH . $type . SEPARATE . $class . '.class.php')) {
                require_once(LIBS_PATH . $type . SEPARATE . $class . '.class.php');
                if ($param != '') {
                    return new $class($param);
                } else {
                    return new $class;
                }
            } else {
                LD("$class is missing");
            }
        }
    }
}